package com.bmf.module.rbac.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bmf.module.rbac.entity.RbacRole;
import com.bmf.module.rbac.service.RbacRoleService;
import com.bmf.module.rbac.vo.RbacRoleCreateVo;
import com.bmf.module.rbac.vo.RbacRoleResultVo;
import com.bmf.module.rbac.vo.RbacRoleUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
import com.bmf.core.result.R;

/**
 * (RbacRole)表控制层
 *
 * @author makejava
 * @since 2022-12-27 15:33:18
 */
@RestController
@RequestMapping("rbacRole")
@Api(tags = {"角色接口"})
public class RbacRoleController {

    /**
     * 服务对象
     */
    @Autowired
    private RbacRoleService rbacRoleService;

    /**
     * 查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R<List<RbacRoleResultVo>> selectAll() {
        List<RbacRoleResultVo> list = rbacRoleService.selectAll();
        return R.success(list);
    }


    /**
     * 新增数据
     *
     * @param rbacRoleCreateVo 实体对象
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R<Integer> insert(@RequestBody RbacRoleCreateVo rbacRoleCreateVo) {
        return R.success(rbacRoleService.insert(rbacRoleCreateVo));
    }

    /**
     * 修改数据
     *
     * @param rbacRoleUpdateVo 实体对象
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R<Void> update(@RequestBody RbacRoleUpdateVo rbacRoleUpdateVo) {
        rbacRoleService.update(rbacRoleUpdateVo);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R<Void> delete(@RequestBody List<Integer> ids) {
        rbacRoleService.delete(ids);
        return R.ok();
    }

    /**
     * 根据id查询
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询")
    public R<RbacRoleResultVo> getOneById(@PathVariable("id") Integer id) {
        RbacRoleResultVo rbacRoleResultVo = rbacRoleService.getOneById(id);
        return R.success(rbacRoleResultVo);
    }

}

